Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​ReadOnlySpan`1

Assembly: System.Runtime

Provides a type-safe and memory-safe read-only representation of a contiguous region of arbitrary memory.

Properties

public bool
IsEmpty
Returns a value that indicates the current read-only span is empty.
public T&
Item
public int
Length
The number of items in the read-only span.

Methods

public void
CopyTo​(Span`1 destination)
public bool
Equals​(object obj)
obj Not supported.
Returns Not supported.
Not supported. Throws a <see cref="T:System.NotSupportedException" /> .
public Enumerator
GetEnumerator​()
Returns An enumerator for this read-only span.
Returns an enumerator for this <see cref="T:System.ReadOnlySpan`1" /> .
public int
GetHashCode​()
Returns Not supported.
Not supported. Throws a <see cref="T:System.NotSupportedException" /> .
public T&
GetPinnableReference​()
Returns A reference to the element of the span at index 0, or <see langword="null" /> if the span is empty.
Returns a read-only reference to an object of type T that can be used for pinning. This method is intended to support .NET compilers and is not intended to be called by user code.
Slice​(int start)
start The zero-based index at which to begin the slice.
Returns A span that consists of all elements of the current span from <paramref name="start" /> to the end of the span.
Forms a slice out of the current read-only span that begins at a specified index.
Slice​(int start, int length)
start The zero-based index at which to begin this slice.
length The desired length for the slice.
Returns A read-only span that consists of <paramref name="length" /> elements from the current span starting at <paramref name="start" /> .
Forms a slice out of the current read-only span starting at a specified index for a specified length.
public T[]
ToArray​()
Returns An array containing the data in the current span.
Copies the contents of this read-only span into a new array.
public string
ToString​()
Returns The string representation of this instance.
Returns the string representation of this <see cref="T:System.ReadOnlySpan`1" /> .
public bool
TryCopyTo​(Span`1 destination)
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .